//
//  PaymentViewController.m
//  quickBatchManager
//
//  Created by 王定波 on 15/10/9.
//  Copyright © 2015年 jack. All rights reserved.
//

#import "PaymentViewController.h"

@interface PaymentViewController ()

@end

@implementation PaymentViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

-(void)initUI
{
    _mainview.layer.cornerRadius=5;
    
    _mainview.layer.shadowRadius = 10.0;
    _mainview.layer.shadowColor = [UIColor blackColor].CGColor; //设置阴影的颜色为黑色
    _mainview.layer.shadowOpacity = 1.0; //设置阴影的不透明度
    _mainview.layer.shadowOffset = CGSizeMake(0, 3);
    
    
    self.view.backgroundColor=[UIColor clearColor];
    
    NSArray *paylist=[[CoreArchive strForKey:NSDEFAULT_ST_PAYMENT] componentsSeparatedByString:@"|"];
    _pay1Field.text=[paylist objectAtIndex:0];
    _pay2Field.text=[paylist objectAtIndex:1];
    _pay3Field.text=[paylist objectAtIndex:2];
    _pay4Field.text=[paylist objectAtIndex:3];
    _pay5Field.text=[paylist objectAtIndex:4];
    
    
    [_dsSwitch setOn:[CoreArchive boolForKey:NSDEFAULT_ST_PAYMENT_DS]];
    [_dsSwitch addTarget:self action:@selector(switchAction:) forControlEvents:UIControlEventValueChanged];
    
    
    
    [_submitBtn bk_whenTapped:^{
        if([_pay1Field.text isBlank] || [_pay2Field.text isBlank] || [_pay3Field.text isBlank] || [_pay4Field.text isBlank] || [_pay5Field.text isBlank])
        {
            [self showAlert:@"支付方式不能为空"];
            return;
        }
        
         [CoreArchive setStr:[NSString stringWithFormat:@"%@|%@|%@|%@|%@",_pay1Field.text,_pay2Field.text,_pay3Field.text,_pay4Field.text,_pay5Field.text] key:NSDEFAULT_ST_PAYMENT];
    }];
    
}


-(void)switchAction:(id)sender
{
    [CoreArchive setBool:_dsSwitch.isOn key:NSDEFAULT_ST_PAYMENT_DS];
}

@end
